#! /usr/bin/python2.4

# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""block_monitor_commit_tests.py unittest"""


import unittest

import svn.fs
import svn.repos

import gvn.hooks.info
import testing.hooks.common

# import RunHook to pass the function pointer to testcommon in unittests
from gvn.hooks.pre_commit.block_monitor_commit_tests \
                                                import RunHook, reject_propname


class TestCase(testing.hooks.common.HookTestCase):

  def testRandomGvnProp(self):
    """Check setting a random revprop works.
    """
    self.assertHookResult(self._TestProp(RunHook, "gvn:foo",
                          "bar", author="basil", path="REV"), 0)

  def testRejectBlockThisCommitProp(self):
    """Check setting gvn:block-this-commit revprop does give us a reject.
    """
    self.assertHookResult(self._TestProp(RunHook, reject_propname,
                          "foo", author="polly", path="REV"),
                          "Rejecting commit as requested by revprop.*")

if __name__ == "__main__":
  unittest.main()
